/**
 * 路由配置验证工具
 * 用于验证路由配置是否正确
 */

import router from '../router/index.js'

/**
 * 验证路由配置
 */
export function validateRouterConfig() {
  const routes = router.getRoutes()
  const errors = []
  
  // 检查必需的路由是否存在
  const requiredRoutes = [
    '/users',
    '/shops', 
    '/scenics',
    '/messages',
    '/reservations'
  ]
  
  requiredRoutes.forEach(path => {
    const route = routes.find(r => r.path === path)
    if (!route) {
      errors.push(`缺少必需的路由: ${path}`)
    } else {
      // 检查路由是否有正确的meta信息
      if (!route.meta || !route.meta.title) {
        errors.push(`路由 ${path} 缺少title meta信息`)
      }
    }
  })
  
  // 检查是否有404路由
  const notFoundRoute = routes.find(r => r.path === '/:pathMatch(.*)*')
  if (!notFoundRoute) {
    errors.push('缺少404路由配置')
  }
  
  return {
    isValid: errors.length === 0,
    errors,
    totalRoutes: routes.length
  }
}

/**
 * 打印路由配置信息
 */
export function printRouterInfo() {
  const routes = router.getRoutes()
  console.log('=== 路由配置信息 ===')
  console.log(`总路由数: ${routes.length}`)
  
  routes.forEach(route => {
    console.log(`路径: ${route.path}`)
    console.log(`名称: ${route.name || '未命名'}`)
    console.log(`标题: ${route.meta?.title || '无标题'}`)
    console.log('---')
  })
}